﻿using UnityEngine;
using System.Collections;

public class PlayerGroundCollideListener : MonoBehaviour {

	public PlayerStateListener targetStateListener = null;
	
	void OnTriggerEnter2D( Collider2D collidedObject)
	{
		switch(collidedObject.tag)
		{
			case "Platform":
				targetStateListener.onStateChange(PlayerStateController.playerState.landing);
			break;
			
			case "DeathTrigger":
				targetStateListener.onStateChange(PlayerStateController.playerState.dead);
			break;
		}
	}
	
	void OnTriggerExit2D( Collider2D collidedObject)
	{
		switch(collidedObject.tag)
		{
			case "Platform":
				if(targetStateListener.currentState != PlayerStateController.playerState.jumping)
					targetStateListener.onStateChange(PlayerStateController.playerState.falling);
			break;
		}         
	}
}
